import 'package:get/get.dart';

import '../common/auth_middleware.dart';

import '../controllers/account_settings_controller.dart';
import '../controllers/chat_controller.dart';
import '../controllers/comment_input_controller.dart';
import '../controllers/login_controller.dart';
import '../controllers/pipe_comment_controller.dart';
import '../controllers/recharge_controller.dart';
import '../controllers/video_topic_detail_controller.dart';
import '../controllers/community_controller.dart';
import '../controllers/edit_username_controller.dart';
import '../controllers/home_controller.dart';
import '../controllers/report_controller.dart';

import '../pages/cartoon_info_page.dart';
import '../pages/comment_input_page.dart';
import '../pages/community_page.dart';
import '../pages/discover_page.dart';
import '../pages/edit_nickname_page.dart';
import '../pages/following_page.dart';
import '../pages/pipe_comment_page.dart';
import '../pages/recharge_page.dart';
import '../pages/report_page.dart';
import '../pages/sample_page.dart';
import '../pages/search_page.dart';
import '../pages/video_category_page.dart';
import '../pages/video_detail_page.dart';
import '../pages/video_list_page.dart';
import '../pages/video_rank_page.dart';
import '../pages/video_topic_detail_page.dart';
import '../pages/web_page.dart';
import '../pages/account_settings_page.dart';
import '../pages/chat_page2.dart';
import '../pages/login_page.dart';
import '../pages/profile_page.dart';
import '../pages/unknown_page.dart';

import '../home_page.dart';

class Routes {
  static const LOGIN = "/login";
  static const HOME = '/home';
  static const SEARCH = '/search';
  static const WEB = '/web';
  static const FOLLOWING = '/following';
  static const PROFILE = "/profile";
  static const CHAT = "/chat";
  static const CARTOON_INFO = "/cartoon_info";
  static const ACCOUNT_SETTINGS = "/account_settings";
  static const REPORT = "/report";
  static const UNKNOWN = "/unknown";
  static const EDIT_NICKNAME = "/edit_nickname";
  static const COMMUNITY = "/community";
  static const DISCOVER = "/discover";
  static const VIDEO_LIST = "/video_list";
  static const VIDEO_RANK = "/video_rank";
  static const VIDEO_DETAIL = "/video_detail";
  static const VIDEO_CATEGORY = "/video_category";
  static const VIDEO_TOPIC_DETAIL = "/video_topic_detail";
  static const SAMPLE = "/sample";
  static const PIPE_COMMENT = "/pipe_comment";
  static const COMMENT_INPUT = "/commment_input";
  static const RECHARGE = "/recharge";

  static var unknown_page = GetPage(name: UNKNOWN, page: () => const UnknownPage());

  static final routes = [
    unknown_page,
    GetPage(
      name: HOME,
      binding: BindingsBuilder(() {
        Get.lazyPut(() => HomeController());
      }),
      page: () => const HomePage(),
    ),
    GetPage(
      name: COMMUNITY,
      page: () => const CommunityPage(),
      binding: BindingsBuilder(() {
        Get.lazyPut(() => CommunityController());
      }),
    ),
    GetPage(
      name: VIDEO_LIST,
      page: () => const VideoListPage(),
    ),
    GetPage(
      name: DISCOVER,
      page: () => const DiscoverPage(),
    ),
    GetPage(
      name: VIDEO_RANK,
      page: () => const VideoRankPage(),
    ),
    GetPage(
      name: VIDEO_DETAIL,
      page: () => const VideoDetailPage(),
    ),
    GetPage(
      name: VIDEO_CATEGORY,
      page: () => const VideoCategoryPage(),
    ),
    GetPage(
      name: Routes.VIDEO_TOPIC_DETAIL,
      page: () => const VideoTopicDetailPage(),
      binding: BindingsBuilder(() {
        Get.lazyPut(() => VideoTopicDetailController());
      }),
    ),
    GetPage(name: SEARCH, page: () => const SearchPage(), middlewares: [AuthMiddleWare()]),
    GetPage(name: WEB, page: () => const WebViewPage()),
    GetPage(name: FOLLOWING, page: () => const FollowingPage(), middlewares: [AuthMiddleWare()]),
    GetPage(name: PROFILE, page: () => const ProfilePage(), middlewares: [AuthMiddleWare()]),
    GetPage(
      name: CHAT,
      page: () => ChatPage2(),
      middlewares: [AuthMiddleWare()],
      binding: BindingsBuilder(() {
        final pipeId = Get.arguments['pipeId'];
        Get.put(ChatController(), tag: pipeId);
      }),
    ),
    GetPage(
      name: CARTOON_INFO,
      page: () => const CartoonInfoPage(),
      middlewares: [AuthMiddleWare()],
      transition: Transition.noTransition,
    ),
    GetPage(
      name: ACCOUNT_SETTINGS,
      page: () => const AccountSettingsPage(),
      binding: BindingsBuilder(() {
        Get.lazyPut(() => AccountSettingsController());
      }),
    ),
    GetPage(
      name: REPORT,
      page: () => const ReportPage(),
      binding: BindingsBuilder(() {
        Get.lazyPut(() => ReportController());
      }),
    ),
    GetPage(
      name: EDIT_NICKNAME,
      page: () => const EditNicknamePage(),
      opaque: false,
      fullscreenDialog: true,
      transition: Transition.noTransition,
      binding: BindingsBuilder(() {
        Get.lazyPut(() => EditUsernameController());
      }),
    ),
    GetPage(
        name: LOGIN,
        page: () => LoginPage(),
        binding: BindingsBuilder(() {
          Get.lazyPut(() => LoginController());
        }),
        opaque: false,
        fullscreenDialog: true,
        transition: Transition.noTransition),
    GetPage(
      name: SAMPLE,
      page: () => const SamplePage(),
    ),
    GetPage(
        name: PIPE_COMMENT,
        page: () => PipeCommentPage(),
        binding: BindingsBuilder(() {
          Get.lazyPut(() => PipeCommentController());
        }),
        opaque: false,
        fullscreenDialog: true,
        transition: Transition.downToUp),
    GetPage(
        name: COMMENT_INPUT,
        page: () => CommentInputPage(),
        binding: BindingsBuilder(() {
          Get.lazyPut(() => CommentInputController());
        }),
        opaque: false,
        fullscreenDialog: true,
        transition: Transition.noTransition),
    GetPage(
      name: RECHARGE,
      page: () => RechargePage(),
      binding: BindingsBuilder(() {
        Get.lazyPut(() => RechargeController());
      }),
    ),
  ];
}
